<?php
namespace Home\Controller;
use Think\Controller;
class ShouyeController extends Controller {
    public function shousuoye(){
    	$fenlei=M('fenlei');
    	$all=$fenlei->select();

        $addbook=M('addbook');
        $vv=$addbook->where("sid=12")->order("id desc")->select();
         if(count($vv) >= 9){
               shuffle($vv);
               $d= array_slice($vv, 0,9);              
          } else {
              $d =  $vv;
          }
        $this->assign('kl',$d);

    	$this->assign('tt',$all);

        $this->display();
    }
    public function abook(){
        $addbook=M('addbook');
        $id=$_POST['id'];
        $count=$addbook->where("sid=$id")->count();
        $page = new \Think\Page($count, 15);
        $page->setConfig('header', '<li class="rows">共<b>%TOTAL_ROW%</b>条记录&nbsp;第<b>%NOW_PAGE%</b>页/共<b>%TOTAL_PAGE%</b>页</li>');
        $page->setConfig('theme', '%FIRST%%UP_PAGE%%LINK_PAGE%%DOWN_PAGE%%END%%HEADER%');
        $page->lastSuffix = false;
        $show=$page->show();
        //$this->assign('page',$show);
        $dal=$addbook->where("sid=$id")->field('title,suotu,id')->order("id desc")->limit($page->firstRow.','.$page->listRows)->select();
        
         if(count($dal) >= 9){
               shuffle($dal);
               $da= array_slice($dal, 0,9);              
          } else {
              $da =  $dal;
          }

        foreach ($da as $k => $v) {
           $id=$v['id'];
                
           $title=$v['title'];
           $imgurl=$v['suotu'];
           
           echo '<div id="kuang" style="height:120px;width:80px;float:left;margin-left:7px;margin-top:5px;">
                <div class="imgg" style="height:110px;width:80px;">
                    <a href="http://jieyue.365festive.com/Home/Xiangqing/sy/id/'.$id.'"><img src="'.$imgurl.'" style="height:100px;width:80px;"></a>
                </div>
                <div class="span" style="width:80px;height:20px;">
                    <a href="'.U('Xiangqing/sy',array('id'=>$id)).'"><li style="font-size:11px;height:20px;line-height:20px;width:80px;text-align:center;overflow: hidden;
              text-overflow: ellipsis;
               white-space: nowrap;">'.$title.'</li></a>
                </div>
            </div>
            '; 
           
        }
       // echo '<div id="fenye" style="float:left;width:100%;height:50px;margin-top:5%;">
       //      <li style="font-size:15px;">'.$show.'<li>
       //      </div> ';
       
        
    }

    public function ssjieguo() {                      
         $keyword = $_POST['guanjianzi'];                         
         if($keyword){
            $data['isbn|keyword|title|writer|content|note'] = array('like',"%$keyword%");
         $book = M('addbook')->field('suotu,title,id,number,writer')->where($data)->select();
     }
        //var_dump($book);
         $this->assign('book',$book);
         $this->display();
    }
}